<?php


namespace App\Http\Controllers\Admin;


use App\Models\AdminUserLog;
use App\Models\AuthGroup;
use App\Models\AuthRule;
use App\Models\MemberOther;
use App\Models\NewAdmin;
use App\Models\ShopUser;
use App\Services\AuthService;
use App\Services\CommonService;
use App\Services\SmsService;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;

class MemberController extends BaseController
{

    public function userList(Request $request){

        $username = $request->input('username','');
        $mobile = $request->input('username','');
        $page = $request->input('page',1);
        $pageSize = $request->input('pageSize',10);
        $createTime=  $request->input('create_time','');
        $where=[];
        if($username){
            $where[] = ['cert_name','like','%'.$username.'%'];
        }
        if($mobile){
            $where[] = ['mobile','like','%'.$mobile.'%'];
        }

        if ($createTime) {
            $createTime = explode('~', $createTime);
            $where[] = ['create_time', '>=', strtotime($createTime[0])];
            $where[] = ['create_time', '<=', strtotime($createTime[1])];
        }

        $memberUser = MemberOther::query()
            ->where($where)
            ->where('mobile','>',0)
            ->select('user_id','cert_name','mobile','cert_no','create_time')
            ->orderBy('create_time','desc')
            ->paginate($pageSize);
        $memberUser = $memberUser?$memberUser->toArray():[];

        foreach ($memberUser['data'] as &$value){
            $value['create_time'] = date('Y-m-d H:i:s',$value['create_time']);
        }
        return ReturnMsg(CommonService::HTTP_CODE_SUCCESS,'获取成功',$memberUser);


    }


}
